package com.wzq.solution;

public class QPlusOne {

    public static int[] plusOne(int[] digits) {

        int t=1;
        for(int i=digits.length-1; i>=0; i--){
            t = digits[i]+t;
            digits[i] = t%10;
            t = t/10;
        }
        if(t==1){
            int[] newDigits = new int[digits.length+1];
            newDigits[0] = 1;
            for(int i=1;i<newDigits.length;i++){
                newDigits[i] = digits[i-1];
            }
            return newDigits;
        }else{
            return digits;
        }

    }

    public static void main(String[] args) {
        int[] digits = new int[]{9};
        plusOne(digits);
    }
}
